﻿
Partial Class Site
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        SiteSettings.FillSiteSettings()

        If (SiteSettings.RequireLogin And Not Page.User.Identity.IsAuthenticated) And Not Request.RawUrl.ToLower.EndsWith("login.aspx") Then
            Response.Redirect(Utils.RelativeWebRoot & "Account/Login.aspx")
        Else
            If Not Page.User.IsInRole("Administrator") Then
                divAdminTools.Visible = False
            End If
            If SiteSettings.OnlyAdminsCanEdit Then
                If Not Page.User.IsInRole("Administrator") Then
                    divAddItem.Visible = False
                    divAddVendor.Visible = False
                End If
            End If

            If Page.User.Identity.IsAuthenticated Then
                divLogin.Visible = False
                divFiller.Visible = False
            Else
                divFiller.Style.Add("cursor", "default")
                If SiteSettings.OnlyAdminsCanEdit Then
                    divFiller.Style.Add("width", "334px")
                End If
                divLogout.Visible = False
                divProfile.Visible = False
            End If

            If Not SiteSettings.SiteMessage = Nothing AndAlso Len(SiteSettings.SiteMessage.Trim) > 0 Then
                lblSiteMessage.InnerText = SiteSettings.SiteMessage
            Else
                lblSiteMessage.Visible = False
            End If
        End If
    End Sub
    
End Class

